//
//  GGNetWorkTool.h
//  cicada
//
//  Created by iOSer on 2016/12/14.
//  Copyright © 2016年 iOSer. All rights reserved.
//

#import "GGResponseResult.h"
#import "GGNetWorkHelper.h"
#import <AFNetworking/AFNetworking.h>
#import "AFHTTPSessionManager.h"
#import "GGNetWorkConnector.h"
@class GGNetWorkConnector;
#define request_mathod_WithName(name) - (GGResponseResult *)name:(NSDictionary *)param success:(void (^)(GGResponseResult *result))success \
dataError:(void (^)(GGResponseResult *result))dataError \
httpError:(void (^)(GGResponseResult *result))httpError;

//是否开启网络DebugLog
static BOOL IS_NETWORK_DEBUGLOG = YES;
//是否开启网络测试URL
static BOOL IS_NETWORK_TESTURL = NO;
//是否中文url自动转码
static BOOL IS_URL_AUTO_ENCODE = NO;


@interface GGNetWorkTool : NSObject

@property (nonatomic, strong) GGNetWorkConnector *connector;

+(instancetype)sharedTools;
///  封装 AFN 的（GET & POST）请求方法
///
///  @param method     HTTP 方法
///  @param url        请求地址
///  @param parameters 参数字典
///  @param timeoutInterval 缓存时间(分钟)
///  @param Progress   进度
///  @param success    成功回调
///  @param failure    失败回调
- (GGResponseResult *)requestWithMethod:(RequestMethod)method
                urlString:(NSString *)url
               parameters:(NSDictionary *)parameters
     CacheTimeoutInterval:(NSInteger)timeoutInterval
                 progress:(void (^)(GGResponseResult *result))Progress
                  success:(void (^)(GGResponseResult *result))success
                  failure:(void(^)(GGResponseResult *result))failure;

///  上传文件
///
///  @param url        请求地址
///  @param parameters 参数字典
///  @param Progress   进度
///  @param success    成功回调
///  @param failure    失败回调
- (GGResponseResult *)uploadWithUrlStr:(NSString *)url
              parameters:(NSDictionary *)parameters
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
                progress:(void (^)(GGResponseResult *result))Progress
                 success:(void (^)(GGResponseResult *result))success
                 failure:(void(^)(GGResponseResult *result))failure;
@end
